import { ADDRESS_LIST, ADDRESS_INFO, ADDRESS_SAVE, ADDRESS_DELETE } from '@constants/address'
import { API_ADDRESS, API_ADDRESS_INFO, API_ADDRESS_SAVE, API_ADDRESS_DELETE } from '@constants/api'
import { createAction } from '@utils/redux'

/**
 * 地址列表
 * @param {*} payload
 */
export const dispatchAddress = payload => createAction({
  url: API_ADDRESS,
  type: ADDRESS_LIST,
  payload
})

/**
 * 地址列表
 * @param {*} payload
 */
export const dispatchAddressInfo = payload => createAction({
  url: API_ADDRESS_INFO,
  type: ADDRESS_INFO,
  payload
})

/**
 * 保存地址
 * @param {*} payload
 */
export const dispatchAddressSave = payload => createAction({
  url: API_ADDRESS_SAVE,
  method: 'POST',
  type: ADDRESS_SAVE,
  payload
})

/**
 * 删除地址
 * @param {*} payload
 */
export const dispatchAddressDel = payload => createAction({
  url: API_ADDRESS_DELETE,
  method: 'POST',
  type: ADDRESS_DELETE,
  payload
})
